package com.yf.stat.modules.course.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yf.base.api.api.dto.PagingReqDTO;
import com.yf.course.modules.course.entity.Course;
import com.yf.course.modules.course.service.CourseService;
import com.yf.stat.modules.course.dto.StatCourseTotalDTO;
import com.yf.stat.modules.course.dto.request.StatCourseFileReqDTO;
import com.yf.stat.modules.course.dto.request.StatCourseLearnReqDTO;
import com.yf.stat.modules.course.dto.response.StatCourseFileDTO;
import com.yf.stat.modules.course.dto.response.StatCourseLearnDTO;
import com.yf.stat.modules.course.mapper.StatCourseMapper;
import com.yf.stat.modules.course.service.StatCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* <p>
* 考试总体统计业务实现类
* </p>
*
* @author 聪明笨狗
* @since 2020-09-11 11:10
*/
@Service
public class StatCourseServiceImpl implements StatCourseService {

    @Autowired
    private CourseService courseService;

    @Autowired
    private StatCourseMapper statCourseMapper;


    @Override
    public StatCourseTotalDTO findOverview(String courseId) {
        Course course = courseService.getById(courseId);
        return statCourseMapper.findOverview(courseId, course.getOpenType());
    }

    @Override
    public IPage<StatCourseFileDTO> fileStatPaging(PagingReqDTO<StatCourseFileReqDTO> reqDTO) {
        return statCourseMapper.fileStatPaging(reqDTO.toPage(), reqDTO.getParams());
    }

    @Override
    public IPage<StatCourseLearnDTO> userStatPaging(PagingReqDTO<StatCourseLearnReqDTO> reqDTO) {
        StatCourseLearnReqDTO params = reqDTO.getParams();
        Course course = courseService.getById(params.getCourseId());
        return statCourseMapper.userStatPaging(reqDTO.toPage(), course.getOpenType(), reqDTO.getParams());
    }

}
